package com.ebook.core.util;

import java.util.Map;

import com.ebook.core.domain.Note;

public class NoteUtil {

	/**
	 * 从map中读取内容解析一个笔记书签的基本信息(map一般是查询数据库返回的结果)
	 * @param map
	 * @return book如果正常，否则返回null
	 */

	public static Note parseNote(Map<String, Object> map) {
		try {
			Integer uid = (Integer)map.get("uid") == null ? 0 : (Integer)map.get("uid") ;
			Integer bookid = (Integer)map.get("bookid") == null ? 0 : (Integer)map.get("bookid") ;
			String noteid = (String)map.get("noteid") == null ? null : (String)map.get("noteid") ;
			String create_time = (String)map.get("create_time") == null ? null : (String)map.get("create_time") ;
			String update_time = (String)map.get("update_time") == null ? null : (String)map.get("update_time") ;
			Integer curr_chapter = (Integer)map.get("curr_chapter") == null ? 0 : (Integer)map.get("curr_chapter") ;
			String select_content = (String)map.get("select_content") == null ? null : (String)map.get("select_content") ;
			String note_content = (String)map.get("note_content") == null ? null : (String)map.get("note_content") ;
			Integer issynronezed = (Integer)map.get("issynronezed") == null ? 0 : (Integer)map.get("issynronezed") ;
			Integer contain_file = (Integer)map.get("contain_file") == null ? 0 : (Integer)map.get("contain_file") ;
			String startCFI = (String)map.get("startCFI") == null ? null : (String)map.get("startCFI") ;
			String endCFI = (String)map.get("endCFI") == null ? null : (String)map.get("endCFI") ;
			Integer note_index = (Integer)map.get("note_index") == null ? 0 : (Integer)map.get("note_index") ;
			Integer isNote = (Integer)map.get("isNote") == null ? 0 : (Integer)map.get("isNote") ;
			String color = (String)map.get("color") == null ? null : (String)map.get("color") ;
			String div_status = (String)map.get("div_status") == null ? null : (String)map.get("div_status") ;
			return new Note(uid, bookid,  noteid,  create_time,
					update_time,curr_chapter,select_content,
					 note_content,issynronezed,contain_file,
					startCFI, endCFI,note_index, isNote,color,div_status);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}	
	}

}
